<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>导游订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        #guide_ul li{
            margin-top: 5px;
        }
    </style>
</head>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">导游订单列表</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">
                        <div class="layui-inline">
                            <label class="layui-form-label">订单编号</label>
                            <div class="layui-input-block">
                                <input type="text" name="order_sn_"  id="order_sn_"  placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">导游名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="name"  placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline" >
                            <label class="layui-form-label" >订单状态</label>
                            <div class="layui-input-block">
                                <select name="order_status_" id="order_status_">
                                    <option value="">全部</option>
                                    <option value="0">待付款</option>
                                    <option value="1">未出行</option>
                                    <option value="2">取消</option>
                                    <option value="3">待评价</option>
                                    <option value="4">完成</option>
                                </select> </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">
                        <a class="layui-btn layui-btn-xs" lay-event="showDetail">详细信息</a> 
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>
<!--导游信息详情-->
<div id="userDetail" style="display: none;padding:20px;">
    <div class="userDetailCen">
        <ul id="guide_ul">
            <li>
                <p class="p-user">订单信息：<span id="food_store_tag"></span></p>
            </li>
            <li>
                <p class="p-user">订单编号：<span id="order_sn"></span></p>
            </li>
            <li>
                <p class="p-user">支付方式：<span id="pay_type"></span></p>
            </li>
            <li>
                <p class="p-user">订单状态：<span id="order_status"></span></p>
            </li>
            <li>
                <p class="p-user">支付时间：<span id="create_time"></span></p>
            </li>
            <li>
            <p class="p-user"> 导游信息：<span id=""></span></p>
            </li>
            <li>
                <p class="p-user">导游名称：<span id="rename"></span></p>
            </li>
            <li>
                <p class="p-user">导游联系方式：<span id="phone"></span></p>
            </li>
            <li>
                <p class="p-user">用户信息：<span id=""></span></p>
            </li>
            <li>
            <p class="p-user">用户名：<span id="username"></span></p>
            </li>
            <li>
                <p class="p-user">成人出行人数：<span id="old_man"></span></p>
            </li>
            <li>
                <p class="p-user">儿童出行人数：<span id="child_man"></span></p>
            </li>
            <li>
                <p class="p-user"> 是否带车：<span id="is_car"></span></p>
            </li>
        </ul>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Order/guidelist')}"
            ,height: 'full-100'
            ,cols: [[
                {field:'order_id',width:80,align:'center', title: 'ID'}
                ,{field:'order_sn',align:'center',title: '订单编号'}
                ,{field:'order_price',align:'center',title: '总价格'}
                ,{field:'rename', align:'center', title: '导游姓名'}
                ,{field:'phone', align:'center', title: '导游手机号'}
                ,{field:'username', align:'center', title: '用户名'}
                ,{field:'order_status', align:'center', title: '订单状态'}
                ,{field:'create_time', align:'center', title: '创建时间'}
                ,{align:'center',width:350, title: '操作', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page:true
            ,limit:20
        });

        form.render(null,'component-form-group');

        laydate.render({
            elem: '#search_time'
        });

        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;
            if(obj.event === 'showDetail'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var order_id = data.order_id;

                $.ajax({
                    url: "{:url('Order/guideOrderDetail')}",
                    type: 'post',
                    dataType: 'json',
                    data: {order_id:order_id},
                    success: function(data){
                        layer.close(loading);
                        if (data.code === 0) {
                            if(data.data.food_store_tag==""){
                                $('#food_store_tag').html('未设置');
                            }else{
                                $('#food_store_tag').html(data.data.food_store_tag);
                            }
                                if(data.data.order_sn ==""){
                                $('#order_sn').html('未设置');
                            }else{
                                $('#order_sn').html(data.data.order_sn);
                            }
                            if(data.data.pay_type==''){
                                $('#pay_type').html('未设置');
                            }else{
                                $('#pay_type').html(data.data.pay_type);
                            }
                            if(data.data.order_status==''){
                                $('#order_status').html('未设置');
                            }else{
                                $('#order_status').html(data.data.order_status);
                            }
                            if(data.data.create_time==''){
                                $('#create_time').html('未设置');
                            }else{
                                $('#create_time').html(data.data.create_time);
                            }
                            if(data.data.rename==''){
                                $('#rename').html('未设置');
                            }else{
                                $('#rename').html(data.data.rename);
                            }
                            if(data.data.phone==''){
                                $('#phone').html('未设置');
                            }else{
                                $('#phone').html(data.data.phone);
                            }
                            if(data.data.rename==''){
                                $('#rename').html('未设置');
                            }else{
                                $('#rename').html(data.data.rename);
                            }
                            if(data.data.old_man==''){
                                $('#old_man').html('未设置');
                            }else{
                                $('#old_man').html(data.data.old_man);
                            }
                            if(data.data.username==''){
                                $('#username').html('未设置');
                            }else{
                                $('#username').html(data.data.username);
                            }
                            if(data.data.child_man==''){
                                $('#child_man').html('未设置');
                            }else{
                                $('#child_man').html(data.data.child_man);
                            }
                            if(data.data.is_car==''){
                                $('#is_car').html('未设置');
                            }else{
                                $('#is_car').html(data.data.is_car);
                            }
                            var userDetailModal = layer.open({
                                title:'导游订单详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['800px']
                                ,content: $('#userDetail')
                            });
                        }else{
                            layer.msg('获取信息失败',{icon:2,time:1000});
                        }


                    }
                })
            }   else if(obj.event === 'food_del'){
                layer.confirm('确认删除编号"' + data.order_sn + '"吗？', function(index){
                    var loading = layer.load(1, {
                        shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: "{:url('Order/delGuide')}",
                        type: 'post',
                        dataType: 'json',
                        data: {id:data.order_id},
                        success: function(msg){
                            layer.close(loading);
                            if (msg.code == 0) {
                                obj.del();
                                layer.msg(msg.msg,{icon:1,time:1000});
                                layer.close(index);
                            }else{
                                layer.msg(msg.msg,{icon:2,time:1000});
                            }
                        }
                    });
                });
            } else if(obj.event === 'sendMerchant'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var guide_id = data.guide_id;
                var guide_tel = data.guide_tel;
                var cardid = data.cardid;
                var rename = data.name;
                $.ajax({
                    url: "{:url('Merchant/sendGuideMerchant')}",
                    type: 'post',
                    dataType: 'json',
                    data: {guide_id:guide_id,guide_tel:guide_tel,cardid:cardid,rename:rename},
                    success: function(data){

                    }
                });
            }else if(obj.event === 'edit'){
                window.location.href="{:url('order/editGuide')}?id=" + data.food_store_id;
            }

        });

        var $ = layui.$, active = {
            addadmin: function() {
                window.location.href="{:url('Merchant/guideAdd')}";
            },
            searchUserButton:function(){
                var order_sn = $('#order_sn_').val();
                var name = $('#name').val();
                var order_status = $("#order_status_").val();

                table.reload('test-table-operate', {
                    where: {
                        order_sn:order_sn,
                        name: name,
                        order_status:order_status
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>